const { createProxyMiddleware } = require('http-proxy-middleware');
// import { createProxyMiddleware } from 'http-proxy-middleware'

module.exports = function(app) {
    app.use(createProxyMiddleware([process.env.REACT_APP_API],{
        // target: 'http://127.0.0.1:3001', // 配置你要请求的服务器地址
        target: process.env.REACT_APP_BASE_URL, // 配置你要请求的服务器地址
        changeOrigin: true,
        pathRewrite:{
            [`^${process.env.REACT_APP_API}`]:''
        }
    }))
    /* console.log(app)
    app.use(createProxyMiddleware('/api',{
        target:'http://127.0.0.1:4000',
        changeOrigin: true,
        pathRewrite:{
          '/api':''
      }
    })) */
    // const apiProxy = createProxyMiddleware('/api', { target: 'http://www.example.org' })
}